package ${package.Controller};


import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Map;
import io.swagger.v3.oas.annotations.tags.Tag;

<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
@Tag(name = "")
<#if restControllerStyle>
@RestController
@CrossOrigin
<#else>
@Controller
@CrossOrigin
</#if>
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != ""></#if>/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
    <#if superControllerClass??>
    public class ${table.controllerName} extends ${superControllerClass} {
    <#else>
    public class ${table.controllerName} {
    </#if>
    @Autowired
    private ${table.serviceName} service;


    @Operation(summary = "分页列表")
    @GetMapping(value = "/page")
    public Result page(@RequestParam Map<String,Object> params) {
        PageData<${entity}DTO> page = service.Page(params);
        //返回结果集
        return new Result().ok(page);
    }

    /**
    * 添加信息
    */
    @PostMapping("add")
    @Operation(summary = "添加信息")
    public Result add(@RequestBody ${entity}DTO dto) {
        return service.Add(dto);
    }

    /**
    * 编辑信息
    */
    @PostMapping("update")
    @Operation(summary = "修改信息")
    public Result update(@RequestBody ${entity}DTO dto) {
        return service.UpdateInfo(dto);
    }


    /**
    * 根据ids删除信息
    */
    @GetMapping("/{id}")
    @Operation(summary = "根据ids删除信息")
    public Result del(@PathVariable("id") Long id){
    boolean n = service.removeById(id);
    if (n) {
    return new Result().ok();
    } else {
    return new Result().err(400, "删除失败");
    }
    }
}
</#if>
